package business.search_eng;

import java.io.IOException;
import java.io.Serializable;

public class Document implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1552708803502271895L;
	
	public Integer id;
	public String title;
	public String subtitle;
	public String author;
	public String content;
	public String url;
	public String date;
	public String topic;
	
	public Document (Integer id,String title,String subtitle,String author,String content,String url,String date,String topic) {
		this.id =id;
		this.title=title;
		this.subtitle=subtitle;
		this.author=author;
		this.content=content;
		this.url=url;
		this.date=date;
		this.topic=topic;		
	}
	
	public String[] getFieldsContents() {
		String fields[] = {this.title, this.subtitle, this.content};
		return fields;
	}
	
	public String[] getFieldsNames() {
		String fields[] = {"title", "subtitle", "body"};
		return fields;
	}
	
	public String showData() {
		StringBuilder sb = new StringBuilder();
		
		sb.append(this.id + " " + this.title + " " +this.url);
		sb.append("\n"+this.subtitle);
		sb.append("\n"+this.author);
		sb.append("\n"+this.content);
		sb.append("\n"+this.topic +" "+this.date);
		
		return sb.toString();
	}
	
	public String htmlData() {
		StringBuilder sb = new StringBuilder();
		sb.append("	<div id='effect' class='ui-widget-content ui-corner-all'>");
		sb.append("<div name='doc' class='expandable'>");
		sb.append("<h3> <a id='num' href='"+this.url+"'>"+this.id+"</a> "+this.title +"</h3>");
		sb.append("<h4>"+this.subtitle +"</h4>");
		sb.append("<h4>by "+this.author +"</h4>");
		sb.append("<p>"+this.content +"<br>"+this.date+"</p>");
		sb.append("<input id='check' type=\"checkbox\" id=\"relevant\" id=\"relevant\" checked>Relevant?</input>");
		sb.append("</div>");
		sb.append("</div>");
		return sb.toString();
	}
	
   /**
   * Always treat de-serialization as a full-blown constructor, by
   * validating the final state of the de-serialized object.
   */
   private void readObject(java.io.ObjectInputStream in)
   				throws ClassNotFoundException, IOException {
	   //always perform the default de-serialization first
	   in.defaultReadObject();
   }

	/**
	* This is the default implementation of writeObject.
	* Customise if necessary.
	*/
   private void writeObject(java.io.ObjectOutputStream out)
   				throws IOException {
	   //perform the default serialization for all non-transient, non-static fields
	   out.defaultWriteObject();
   }


}
